package cn.edu.scau.cmi.liangzijian.client;

import cn.edu.scau.cmi.liangzijian.proxy.common.CGeneralVisit;
import cn.edu.scau.cmi.liangzijian.proxy.common.CVipVisit;
import cn.edu.scau.cmi.liangzijian.proxy.common.CVisit;
import cn.edu.scau.cmi.liangzijian.proxy.common.CVisitProxy;
import cn.edu.scau.cmi.liangzijian.proxy.dynamic.DGeneralVisit;
import cn.edu.scau.cmi.liangzijian.proxy.dynamic.DVipVisit;
import cn.edu.scau.cmi.liangzijian.proxy.dynamic.DVisit;
import cn.edu.scau.cmi.liangzijian.proxy.dynamic.DVisitProxy;

public class ProxyClient {
	public static void main(String[] args) {
		//commonVisit();
		dynamicVisit();
	}
	
	public static void commonVisit() {
		CVisit cVisit = new CVipVisit();
		CVisit proxy = new CVisitProxy(cVisit);
		proxy.browse();
		proxy.comment();
		proxy.download();
		
		cVisit = new CGeneralVisit();
		proxy = new CVisitProxy(cVisit);
		proxy.browse();
		proxy.comment();
		proxy.download();
	}
	
	public static void dynamicVisit() {
		DVisit dVisit = new DVipVisit();
		DVisit proxy = DVisitProxy.newProxyInstance(dVisit);
		proxy.browse();
		proxy.comment();
		proxy.download();
		
		dVisit = new DGeneralVisit();
		proxy = DVisitProxy.newProxyInstance(dVisit);
		proxy.browse();
		proxy.comment();
		proxy.download();
	}
}
